# -*- coding:utf-8 -*-
"""
@Author : 审心
@Time : 2023/4/17 9:54
"""
from dataclasses import dataclass
from typing import List


import config
from common.redis.util import RedisUtil
from common.utils import ObjUtil

redis_client = RedisUtil(host=config.data.get("redis.url"), port=config.data.get("redis.port"),
                         db=config.data.get("redis.db"))


@dataclass
class T:
    username: str
    age: int
    port: List[int]


if __name__ == '__main__':
    redis_client.put('test:text', '123')
    redis_client.put('test:text1', 123)
    redis_client.put('test:text2', {'text': '无外芜湖'})
    redis_client.put('test:text3', [1, 2, 3, 4])
    redis_client.put('test:text4', T('test1', 11, [123, 454]))
    redis_client.put('test:text5',
                     [ObjUtil.to_dict(item) for item in [T('test1', 11, [123, 454]), T('test1', 11, [123, 454])]])
    print(redis_client.get("test:text5", list))
    print(redis_client.get("test:text2", dict))
    print(redis_client.get("test:*", dict))
    print(redis_client.get("test:", str))
